/**
  ******************************************************************************
  * File   : PT32U303_PT5616_SLPMSM_SGSN_SW_V1.0.0/main.c 
  * Version: V1.0.0
  * Date   : 2022-11-28
  * Brief  : Main program body
  ******************************************************************************
  */ 
//
/* Includes ------------------------------------------------------------------*/
#include <stdio.h>
#include "PT32U303.h"
//----------------------
#include "GloVarDef.h"
//----------------------
#include "MotorInit.h"
#include "MotorCtrl.h"
#include "PropInteDiff.h"
#include "ProcessTimer.h"
#include "Protect.h"
#include "OtherCtrl.h"
//
/**
  * @brief  Main Function.
  * @param  None
  * @retval None
  */
int main(void)
{
    MCUDBU_Configuration();
    //
    RCC_Configuration();
    //
    NVIC_Configuration();
    //
    UART_Print_Init(115200);
    //
    GPIO_Configuration();
    //
    ADC_Configuration();
    //
    TIM1_Configuration();
    //
    TIM6_Configuration();
    //
    #if ((DEBUG_INFOR_OUTPUT == 0) && (DEBUG_FOC_OUTPUT == 0))
    {
        IWDG_Configuration();
    }
    #endif
    //
    #if (DEBUG_INFOR_OUTPUT == 1)
    {
        printf("PT32U303_PT5616_SLPMSM_SGSN_SW_V1.0.0 Sample Code\r\n");
        printf("SystemCoreClock = %ldHz\r\n",SystemCoreClock);
        printf("g_PWM_Frequency = %dhz\r\n",g_PWM_Frequency);
        printf("g_PWM_Period = %dns\r\n",g_PWM_Period);
        printf("g_PWMLoadData = %d\r\n",g_PWMLoadData);
        printf("g_VoltageMotor = %d\r\n",g_VoltageMotor);
    }
    #endif
    //
    DEBUG_PB09_OFF;
    while(1)
    {
        IWDG_ReloadCounter();
        //
        ProcessTimer();
        //
        DirRotate();
        //
        LRCP_Ctrl();
        //
        UVP_Ctrl();
        //
        OVP_Ctrl();
        //
        OCP_Ctrl();
        //
        OTP_Ctrl();
        //
        ACP_Ctrl();
        //
        MotorCtrl();
        //
        LED_Ctrl();
    }
}


#ifdef  USE_FULL_ASSERT
/**
  * @brief  Reports the name of the source file and the source line number
  *         where the assert_param error has occurred.
  * @param  file: pointer to the source file name
  * @param  line: assert_param error line source number                //
                //
  * @retval None
  */
void assert_failed(uint8_t* file, uint32_t line)
{
  /* User can add his own implementation to report the file name and line number*/
  
    printf("Wrong parameters value: file %s on line %d\r\n", file, line);

  /* Infinite loop */
    /*while (1)
      {}*/
}
#endif

/**
  * @}
  */

/**
  * @}
  */



